<?php
# [useage]
#   qr_img.php?d=[data]&e=[(L,M,Q,H)]&s=[int]&v=[(1-40)]
#             (&m=[(1-16)]&n=[(2-16)](&p=[(0-255)],&o=[data]))
#
#   d= data         URL encoded data.
#   e= ECC level    L or M or Q or H   (default M)
#   s= module size  (dafault PNG:4 JPEG:8)
#   v= version      1-40 or Auto select if you do not set.
#   t= image type   J:jpeg image , other: PNG image
#
#  structured append  m of n (experimental)
#   n= structure append n (2-16)
#   m= structure append m (1-16)
#   p= parity
#   o= original data (URL encoded data)  for calculating parity
#
function QRcode($d, $e = 'M', $s = null, $v = null, $t = 'P', $m = null, $n = null, $o = null, $p = null)
{
  $path  = '/QRcodePlugin/qr_img/php/qr_img.php';
  $url   = $path . '?d=' . $d;
  if ($e && in_array(strtoupper($e), array('L', 'M', 'Q', 'H'))) {
    $url .= '&e=' . strtoupper($e);
  } else { 
    $url .= '&e=M';
  }
  if ($s) {
    $url .= '&s=' . $s;
  }
  if ($v) {
    $url .= '&v=' . $v;
  }
  if ($t) {
    $url .= '&t=' . $t;
  }
  if ($m) {
    $url .= '&m=' . $m;
  }
  if ($n) {
    $url .= '&n=' . $n;
  }
  if ($o) {
    $url .= '&o=' . $o;
  }
  if ($p) {
    $url .= '&p=' . $p;
  }

  $output = image_tag($url, array('alt' => $d));
  return $output;
}

